package com.lanou.sfu.songforu.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.sfu.songforu.fragment.MyFragment;
import com.lanou.sfu.songforu.fragment.RecommendFragment;
import com.lanou.sfu.songforu.mv.MvActivityFragment;

import java.util.ArrayList;

/**
 * Created by quyan on 15/10/21.
 */
//滑动标题适配器
public class MenuAdapter extends FragmentPagerAdapter {

    private ArrayList<Fragment> datas;

    public MenuAdapter(FragmentManager fm) {
        super(fm);
        addData();

    }

    public ArrayList<Fragment> getDatas() {
        return datas;
    }

    public void addData(){
        datas = new ArrayList<>();
        datas.add(new MyFragment());
        datas.add(new RecommendFragment());
        datas.add(new com.lanou.sfu.songforu.music_library_fragment.MusicLibraryFragment());
        datas.add(new MvActivityFragment());
        notifyDataSetChanged();
    }
    @Override
    public Fragment getItem(int position) {

        return datas != null && datas.size() > 0 ? datas.get(position) : null;
    }

    @Override
    public int getCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }


}

